<?php
namespace Home\Controller;
use Think\Controller;
// 开发者：杨晓杰，
// 邮箱：2902468225@qq.com


// 页面控制器，负责打开页面
class IndexController extends Controller {
        private function indexContent(){
                //banner内容
                $data['banner']=M('banner')->where('status = 1')->order('sort asc')->select();
                // 热门学生
                $data['hot_student']=M('student')->order('parise desc')->limit(3)->select();
                // 热门企业
                $all=M('campany')->where('is_verify = 1')->order('parise desc')->select();

                $data['hot_company']=R('Myfunc/Myfunc/pageDeal',array('data'=>$all));

                //添加是否点赞过
                $length=count($data['hot_company']['list']);
                $where['ip']=get_client_ip();
                $where['aim_type']=2;
                for($i=0;$i<$length;$i++){
                        $where['aim_id']=$data['hot_company']['list'][$i]['id'];
                        if(M('parise')->where($where)->find())$data['hot_company']['list'][$i]['is_parise']=1;
                        else $data['hot_company']['list'][$i]['is_parise']=0;
                }

                $data['areaList']=M('area')->order('hot desc')->select();
                $data['indusList']=M('industry')->order('hot desc')->select();

                $data['type']=1;//主页
                return $data;
        }
	public function index(){
                tag('func');
                $data=$this->indexContent();
                $this->assign('data',$data);
        	R('Page/index');
	}
        // 发现企业
        public function foundCompany(){
                tag('func');
                $data=$this->indexContent();
                // dump($data['hot_company']);
                $this->assign('data',$data);
                R('Page/foundCompany');
        }
        // 发现人才
        public function foundStudent(){
                tag('func');
                $data=$this->indexContent();
                // dump($data['hot_company']);
                $this->assign('data',$data);
                R('Page/foundStudent');
        }
        public function like(){
                tag('func');
                //banner内容
                $data['banner']=M('banner')->where('status = 1')->order('sort asc')->select();
                // 热门学生
                $data['hot_student']=M('student')->order('parise desc')->limit(3)->select();
                // 热门企业
                $all=M('campany')->where('is_verify = 1')->order('parise desc')->select();
                $data['hot_company']=R('Myfunc/Myfunc/pageDeal',array('data'=>$all));
                $data['areaList']=M('area')->order('hot desc')->select();
                $data['indusList']=M('industry')->order('hot desc')->select();

                $data['type']=2;//like
                // dump($_ENV);
                $this->assign('data',$data);
                R('Page/like');
        }
        public function likeCpn(){
                tag('func');

                // 热门企业
                $all=M('campany')->where('is_verify = 1')->order('parise desc')->select();
                $data['hot_company']=R('Myfunc/Myfunc/pageDeal',array('data'=>$all));
                $data['areaList']=M('area')->order('hot desc')->select();
                $data['indusList']=M('industry')->order('hot desc')->select();

                $data['type']=2;//like
                // dump($_ENV);
                $this->assign('data',$data);
                R('Page/likeCpn');
        }
        public function likeStd(){
                tag('func');
                // 热门学生
                //$data['hot_student']=M('student')->order('parise desc')->limit(3)->select();
                $data['type']=2;//like
                // dump($_ENV);
                $this->assign('data',$data);
                R('Page/likeStd');
        }
        public function popurlarity(){
                tag('func');
                //banner内容
                $data['banner']=M('banner')->where('status = 1')->order('sort asc')->select();
                // 热门学生
                $data['hot_student']=M('student')->order('parise desc')->limit(3)->select();
                // 热门企业
                $all=M('campany')->where('is_verify = 1')->order('parise desc')->select();
                $data['hot_company']=R('Myfunc/Myfunc/pageDeal',array('data'=>$all));
                $data['areaList']=M('area')->order('hot desc')->select();
                $data['indusList']=M('industry')->order('hot desc')->select();

                $data['type']=3;//人气王
                // dump($_ENV);
                $this->assign('data',$data);
                R('Page/popurlarity');
        }
        public function aboutUs(){
                tag('func');
                R('Page/aboutUs');
        }
        // 搜索页面
        public function search(){
                tag('func');
                R('Page/search');
        }
}